﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="CadastroJogos.aspx.cs" Inherits="SFsoftSite.Cadastros.CadastroJogos" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
     <h1 style = "padding-left: 30px">
        Cadastro de Jogos
    </h1>

    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <table align="left">
                <tr>
                    <td style="text-align:right; width:30%">
                        <asp:Label ID="Label1" runat ="server" Text = "Nome: "/>
                    </td>
                    <td style="text-align:left; width:70%">
                        <asp:TextBox ID="txtTitulo" MaxLength="50" runat="server" Width="359px"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td style="text-align:right; width:30%">
                        <asp:Label ID="Label4" runat ="server" Text = "Descricao "/>
                    </td>
                    <td style="text-align:left; width:70%">
                        <asp:TextBox ID="txtDescricao" MaxLength="255" Height="100px" TextMode="MultiLine" runat="server"  Width="359px"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td style="text-align:right; width:30%">
                        <asp:Label ID="Label5" runat ="server" Text = "Categoria: "/>
                    </td>
                    <td style="text-align:left; width:70%">
                        <asp:DropDownList ID="ddlCategoria" runat="server" DataSourceID="SQLCategoria" 
                            DataTextField="Nome" DataValueField="ID">
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="SQLCategoria" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:ConnectionStringCategorias %>" 
                            SelectCommand="SELECT * FROM [Categoria]"></asp:SqlDataSource>
                    </td>
                </tr>
                <tr>
                    <td style="text-align:right; width:30%">
                        <asp:Label ID="lblProd" runat ="server" Text = "Produtora: "/>
                    </td>
                    <td style="text-align:left; width:70%">
                        <asp:DropDownList ID="ddlProdutora" runat="server" 
                            DataSourceID="SQLBancoGlauco" DataTextField="Nome" DataValueField="ID">
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="SQLBancoGlauco" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:ConnectionStringCategorias %>" 
                        SelectCommand="SELECT * FROM [Produtora]"></asp:SqlDataSource>
                    </td>
                </tr>
                <tr>
                    <td style="text-align:right; width:30%">
                        <asp:Label ID="Label3" runat ="server" Text = "Preco "  Width="359px"/>
                    </td>
                    <td style="text-align:left; width:70%">
                        <asp:TextBox ID="txtPreco" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td style="text-align:right; width:30%">
                        <asp:Label ID="Label2" runat ="server" Text = "Foto: "/>    
                    </td>
                    <td style="text-align:left; width:70%">
                        <asp:FileUpload ID="FileUpload1" runat="server"></asp:FileUpload>
                    </td>
                </tr>
                <tr>
                    <td style="text-align:right; width:30%">  
                    </td>
                    <td style="text-align:left; width:70%">
                        <br />
                        <asp:Button ID="Button1" Text= "Cadastrar" runat ="server"  OnClick = "CadastrarJogo"/>
                        <br />
                        <br />
                    </td>
                </tr>
        </table>
    <br/>
    <div align="center">
    <asp:Label ID="lblMessage" runat="Server"></asp:Label>

            <asp:GridView ID="GridView1" runat="Server" AutoGenerateColumns="False" BorderWidth="1"
                DataKeyNames="Id" AutoGenerateEditButton="false" OnRowEditing="EditRecord"
                OnRowCancelingEdit="CancelRecord" OnRowUpdating="UpdateRecord" CellPadding="4"
                HeaderStyle-HorizontalAlign="left" OnRowDeleting="DeleteRecord" RowStyle-VerticalAlign="Top"
                ForeColor="#333333" GridLines="None">
                <Columns>
                    <asp:CommandField ButtonType="Button" ShowDeleteButton="false" ShowEditButton="true" EditText="Editar" DeleteText="Deletar" UpdateText="Atualizar" CancelText="Cancelar" />
              
                    <asp:BoundField DataField="Id" HeaderText="Id do Jogo" ReadOnly="True" />

                    <asp:TemplateField HeaderText="ID Produtora">
                        <ItemTemplate>
                            <%# Eval("Produtora") %>
                        </ItemTemplate>
                        <EditItemTemplate>
                        <asp:DropDownList ID="txtProdutora" runat="server" 
                        DataSourceID="SQLBancoGlauco" DataTextField="Nome" DataValueField="ID">
                         </asp:DropDownList>
                         <asp:SqlDataSource ID="SQLBancoGlauco" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:ConnectionStringCategorias %>" 
                        SelectCommand="SELECT * FROM [Produtora]"></asp:SqlDataSource>
                            <asp:RequiredFieldValidator ID="req1" runat="Server" Text="*" ControlToValidate="txtProdutora"></asp:RequiredFieldValidator>
                        </EditItemTemplate>
                    </asp:TemplateField>

                    <asp:TemplateField HeaderText="Titulo">
                        <ItemTemplate>
                            <%# Eval("Nome")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txtPageDesc" runat="Server" 
                                Text='<%# Eval("Nome") %>'></asp:TextBox>
                            <asp:RequiredFieldValidator ID="req2" runat="Server" Text="*" ControlToValidate="txtPageDesc"></asp:RequiredFieldValidator>
                        </EditItemTemplate>

                    </asp:TemplateField>
                           <asp:TemplateField HeaderText="Categoria">
                        <ItemTemplate>
                            <%# Eval("Categoria")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                          <asp:DropDownList ID="txtCategoria" runat="server" DataSourceID="SQLCategoria" 
                            DataTextField="Nome" DataValueField="ID">
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="SQLCategoria" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:ConnectionStringCategorias %>" 
                            SelectCommand="SELECT * FROM [Categoria]"></asp:SqlDataSource>
                            <asp:RequiredFieldValidator ID="req12" runat="Server" Text="*" ControlToValidate="txtCategoria"></asp:RequiredFieldValidator>
                        </EditItemTemplate>

                    </asp:TemplateField>
                      <asp:TemplateField HeaderText="Preco">
                        <ItemTemplate>
                            <%# Eval("Preco")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txtPrecoGrid" runat="Server" 
                                Text='<%# Eval("Preco") %>'></asp:TextBox>
                            <asp:RequiredFieldValidator ID="req9" runat="Server" Text="*" ControlToValidate="txtPrecoGrid"></asp:RequiredFieldValidator>
                        </EditItemTemplate>

                    </asp:TemplateField>
                     <asp:TemplateField HeaderText="Descricao">
                        <ItemTemplate>
                            <%# Eval("Descricao")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txtDescricaoGrid" runat="Server" 
                                Text='<%# Eval("Descricao") %>'></asp:TextBox>
                            <asp:RequiredFieldValidator ID="req93" runat="Server" Text="*" ControlToValidate="txtDescricaoGrid"></asp:RequiredFieldValidator>
                        </EditItemTemplate>

                    </asp:TemplateField>
                     <asp:TemplateField HeaderText="Imagem">
                        <ItemTemplate>
                            <%# Eval("Foto")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txtImagem" runat="Server"
                                Text='<%# Eval("Foto") %>'></asp:TextBox>
                            <asp:RequiredFieldValidator ID="req53" runat="Server" Text="*" ControlToValidate="txtImagem"></asp:RequiredFieldValidator>
                        </EditItemTemplate>
                    </asp:TemplateField>

                    <asp:TemplateField HeaderText="Delete">
                        <ItemTemplate>
                            <span onclick="return confirm('Tem certeza que deseja deletar?')">
                                <asp:Button Text = "Deletar" ID ="lnkB" runat = "server" CommandName ="Delete"/>
                            </span>
                        </ItemTemplate>
                    </asp:TemplateField>

                </Columns>

                <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />

                <RowStyle BackColor="#FFFBD6" ForeColor="#333333" VerticalAlign="Top" />

                <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />

                <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />

                <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />

                <AlternatingRowStyle BackColor="White" />

            </asp:GridView> 
            
            </div>

        </ContentTemplate>
        <Triggers>
            <asp:PostBackTrigger ControlID="Button1">
            </asp:PostBackTrigger>
        </Triggers>
        </asp:UpdatePanel>
        <br />
        <br />
     

</asp:Content>
